package com.iwhalecloud.bss.kite.cucc.service.attr.handler;

import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.service.attr.LocalAttrHelper;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import com.iwhalecloud.bss.kite.service.attr.handler.AbstractAttrHandler;

import java.util.Objects;

/**
 * @Classname ServiceTypeAttrHandler
 * @Description  服务类型为周期性，则显示周期频次，否则不显示
 * @Date 2021-08-06 16:35
 */
public class ServiceTypeAttrHandler extends AbstractAttrHandler<KiteInst, AttrData> {

    @Override
    public void set(KiteAttr attr, KiteInst inst, String value, AttrData data) {
        super.set(attr, inst, value, data);
        String fieldName = attr.getFieldName();


        switch (fieldName) {
            case "210004890":
                // 服务类型为周期性，则显示周期频次，否则不显示
                KiteAttr attr1 = inst.getAttr("200001079");
                if(attr.getValue().contains("100000770")) {
                    if (Objects.nonNull(attr1)) {
                        LocalAttrHelper.hiddenOrDisplayProdAttr(data.getSceneInstId(), inst, attr1, KeyConsts.PROD_ATTR_SHOW_TYPE_D, attr1.getValue());
                    }
                } else {
                    if (Objects.nonNull(attr1)) {
                        LocalAttrHelper.hiddenOrDisplayProdAttr(data.getSceneInstId(), inst, attr1, KeyConsts.PROD_ATTR_SHOW_TYPE_E, "");
                    }
                }
                break;
            default:
                break;
        }
    }
}
